/*
    testWebSocketsHandler.c -- Test handler to assist when developing web sockets apps

    Copyright (c) All Rights Reserved. See copyright notice at the bottom of the file.
 */
#include    "appweb.h"

#if ME_COM_TEST_WEBSOCKETS

static int test_open(HttpQueue *q)
{
    return 0;
}

static void test_close(HttpQueue *q)
{
}

static void test_incoming(HttpQueue *q, HttpPacket *packet)
{
    // 3K
    char *data =
        "\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
0123456789012345678901234567890123456789012345678\n\
END OF DOCUMENT\n";

    httpSendBlock(q->stream, WS_MSG_TEXT, data, slen(data), 0);
}

static void test_ready(HttpQueue *q)
{
}

PUBLIC int httpTestWebSocketsInit(Http *http, MprModule *module)
{
    HttpStage *handler;

    handler = httpCreateHandler("testWebSocketsHandler", module);

    handler->open = test_open;
    handler->incoming = test_incoming;
    handler->ready = test_ready;
    handler->close = test_close;
    return 0;
}

#endif

/*
    Copyright (c) Embedthis Software. All Rights Reserved.
    This software is distributed under a commercial license. Consult the LICENSE.md
    distributed with this software for full details and copyrights.
 */
